#ifndef					__LISTENER_H_
# define				__LISTENER_H_

# include				<QObject>
# include				<string>
# include				<cstdlib>
# include				"portaudio.h"
# include				<queue>
# include				<qmutex.h>
# include				"SoundRotatingBuffer.h"
# include				"IListener.h"

class					Listener : public QObject, public IListener
{
	Q_OBJECT

public:
	Listener();
	~Listener();

public:
	void				init();
	int					record(const short *);
	void				start();
	void				stop();
	size_t				getFPB() const;
	size_t				getChannelNB() const;
	size_t				getSampleRate() const;
	void				read(ISoundPacket*);


private:
	SoundRotatingBuffer	_buffer;
	int					_frameIndex;
	PaStream			*_stream;
	size_t				_sample_rate;
	size_t				_frames_per_buffer;
	size_t				_num_channels;
	int					_status;

signals:
	void				_readBufferFull();
};

#endif // !__LISTENER_H_
